Repository navigation
Conversation
… country (failing) Household jobs take and store a dynamic_id, household reports and their re-runs take one per side, and each merges the dynamic's values into the household reform, as economy simulations do. Every simulation refuses a dynamic stored for another country. The insert_dynamic test helper writes the columns API v1's revision 9d1d12a7ac58 requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ther country's Household jobs take a dynamic_id, store it in household_jobs.dynamic_id and return it in the job's state; household reports and their re-runs take one per side. Each reads the policy's and the dynamic's values together with the new read_simulation_reform, as economy simulations now do too, so a parameter both set is refused. The household report key already names each side's dynamic, and a stored household report naming one is now re-run with it instead of refused. The Dynamic model gains country_id, and read_dynamic_reform refuses a dynamic stored for another country as UnknownDynamicError, which every route answers as unknown_dynamic. A value the household contract refuses is located at dynamic_id when the dynamic sets its parameter. public-api-commit moves to 003ee4996, API v1's merge of PolicyEngine/policyengine-api#4325, whose revision 9d1d12a7ac58 gives dynamics their country. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and require dynamic_parameters Review round 1 found two existing tests that the change broke: a route case still expected a household report side's dynamic_id to be refused, and the generated-client test read a household job state without the now-required dynamic_id. Both now expect the new shapes, and new route and generated-client tests send each side's dynamic and read it back. The inputs that carry which parameters a dynamic sets now require them, so no caller can leave them out and have a refused dynamic value located at policy_id. The README paragraphs this change edited are rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h its dynamic's parameters Review round 2 found no bugs. Its quality findings: - Economy requests and household reports now build the refusal of a simulation's policy or dynamic with one function, simulation_values_refusal, so each says the same thing and locates it the same way. The household calculation route keeps its own refusals, whose details and error types differ. - The household inputs carry each side's SimulationReform, the combined values with the parameters its dynamic sets, instead of two parallel fields. - The entry README's re-run refusals and the CallerRowRefusalCode comment name the dynamic refusals, and two README paragraphs are rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1112
Household calculations and household reports now apply a dynamic, as economy simulations do. Every simulation now refuses a dynamic stored for another country. The persistence library's pinned API v1 commit moves to
003ee4996(PolicyEngine/policyengine-api#4325).What changes
Persistence library
Dynamicgainscountry_id.read_dynamic_reformtakes the country and raisesUnknownDynamicErrorfor a dynamic stored for another country, asread_policy_reformdoes for a policy.read_simulation_reformreads a simulation's policy and dynamic and combines them withcombine_reforms, which refuses a parameter both set. It returns aSimulationReformholding the values and the names of the dynamic's parameters. Every reader uses it:read_simulation_values;HouseholdJobStore.read_inputs, which now takesdynamic_id;HouseholdReportStore.read_inputs, which now takes each side'sSimulationChoiceinstead of policy IDs.NewHouseholdJobandHouseholdJobRecordgaindynamic_id, stored inhousehold_jobs.dynamic_id.dynamic_id; it was always null.public-api-commitmoves to003ee49965a2190e0e5c78f7e946b4bb100c0f16.insert_dynamicwritesdynamics' new required columns instead ofname.Simulation Entrypoint
POST /household-calculationstakesdynamic_id, andGET /household-calculations/{id}returns it.HouseholdPolicyChoice) takesdynamic_id. A stored household report whose side names a dynamic is now re-run with it, where it used to be refused with 409.unknown_dynamic, also for a dynamic of another country;missing_parametersatdynamic_id, for a dynamic setting parameters the catalog version lacks;overlapping_parametersatdynamic_id, for a dynamic setting a parameter the policy also sets.dynamic_idwhen the dynamic sets its parameter.simulation_values_refusal. Theunknown_dynamicdetail now names the country.The v1
run_simulationcode imports nothing this adds. API v1 sends no householddynamic_iduntil C1 · 45.Tests
1717addacommitted the failing tests. Then 29 of 50 persistence cases and 40 of 54 entry cases failed, for the expected reasons.003ee4996, with its privilege manifest applied.scripts/generate-clients.sh.main, all five comparisons also pass at003ee4996. Between63cce8273and003ee4996, API v1's tables changed only indynamicsand in tables sim doesn't model.Deploy order
Production must have API v1's revision
9d1d12a7ac58before this releases.dynamics.country_idwhenever a request, or a stored record being re-run, names a dynamic.database_unavailable, where it is answered 400 today. Requests without a dynamic don't readdynamics, and no readiness check reads the column.mainreleases and deploys by itself, so this PR should merge only after API v1's production release containing #4325.Read from GitHub on 2026-11-20:
80a42ddeb, which follows003ee4996, has a Push run still marked in progress.Seed staging v2 databasejob succeeded, so staging has the revision.Upgrade staging v1 Cloud SQL schemafailed.Grants
From API v1's
privileges.pyat003ee4996, no new grant is needed:dynamics: table-levelSELECTfor the simulation service role and the Modal worker role.household_jobs:SELECT, INSERTfor the service role, so it can insertdynamic_id, plusUPDATEon the call-start columns.simulations,parameter_values,parameters,policies,householdsand the catalog: unchanged.The persistence tests ran as
policyengine_v2_simulation_serviceon a database with those grants applied. Sim's readiness list (SERVICE_TABLE_PRIVILEGES) already requiresSELECTondynamics.Pin order with #1111, and overlap
003ee4996.insert_dynamicto exactly this PR's form.main, keeps the pin at C1 · 41's merge commit (never back at003ee4996) and keeps the identicalinsert_dynamichunk. Its changed tests then run again on a database built at that commit.main, so Start each side's cliff calculation when a report asks for cliffs #1099's and Drop the report columns API v1 removes from sim's table models #1111's lists include Calculate each simulation run's cliff gap and share as its own cliff result #1096's files:libs/policyengine-simulation-persistence/README.md,libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/__init__.py.projects/policyengine-simulation-entry/README.md,.../economy_api_models.py,.../rerunnable_records.py,tests/test_economy_submissions.pyandtests/test_openapi.py.libs/policyengine-simulation-persistence/tests/test_keyed_household_records.py,projects/policyengine-simulation-entry/README.mdand.../household_report_reruns.py.git merge-treeof this head with each of their heads is clean today.public-api-commitandtests/public_api_rows.pywill conflict once Calculate each simulation run's cliff gap and share as its own cliff result #1096 or Drop the report columns API v1 removes from sim's table models #1111 moves the pin.Review
dynamic_idto be refused;dynamic_id.SimulationReformpassed through, and documentation.🤖 Generated with Claude Code